from flask import Blueprint
from flask import redirect
from flask import request
from flask import session

admin_blu = Blueprint("admin",__name__,url_prefix="/admin")
from . import views


@admin_blu.before_request
def check_admin():
    is_admin = session.get("is_admin", False)
    # 所以要排除掉管理员登录页面，让管理员可以登录   (不是管理员，并且请求不是管理页面)
    if not is_admin and not request.url.endswith("/admin/login"):
        return redirect("/")